<?php
require_once $_SESSION["app_root"]."config/app.config.php";
class Store
{
	public $id;
	public $ProxyURL;
	public $EntityID;
	public $Columns;
	public $JsonColumns;
	public function Store($EntityID){
		$this->setId($EntityID);
		$this->setProxyURL($_SESSION['app_uri']."server/database.php");
		$this->setEntityID($EntityID);
		$this->generateColumns();
	}
	public function generateColumns(){
		$colimnList = array();
		//vp($this);
		$colQuery = "SELECT * FROM grid_store_def WHERE entity_id = '".$this->EntityID."'";
		$db = new Database();
			$columnsArr = $db -> rawSelect($colQuery);
		$db -> close();
		$cols = array();
		$jsonCols = "";
		foreach($columnsArr as $val){
			 $jsonCols .= ", {name: '".$val['name']."', type: '".$val['type']."', mapping: '".$val['mapping']."'}";
			 $storeColumn = new StoreColumn();
			 $storeColumn->setName($val['name']);
			 $storeColumn->setType($val['type']);
			 $storeColumn->setMapping($val['mapping']);
			 array_push($cols, $storeColumn);
		}
		$jsonCols = substr($jsonCols, 1);
		$this->setJsonColumns("[".$jsonCols."]");
		$this->setColumns($cols);
	}

    /**
     * Gets $jsonColumns.
     * @see Store::$jsonColumns
     */
    public function getJsonColumns()
    {
        return $this->JsonColumns;
    }
    
    /**
     * Sets $jsonColumns.
     * @param object $jsonColumns
     * @see Store::$jsonColumns
     */
    public function setJsonColumns($jsonColumns)
    {
        $this->JsonColumns = $jsonColumns;
    }

    /**
     * Gets $Columns.
     * @see Store::$Columns
     */
    public function getColumns()
    {
        return $this->Columns;
    }
    
    /**
     * Sets $Columns.
     * @param object $Columns
     * @see Store::$Columns
     */
    public function setColumns($Columns)
    {
        $this->Columns = $Columns;
    }
    
    /**
     * Gets $EntityID.
     * @see Store::$EntityID
     */
    public function getEntityID()
    {
        return $this->EntityID;
    }
    
    /**
     * Sets $EntityID.
     * @param object $EntityID
     * @see Store::$EntityID
     */
    public function setEntityID($EntityID)
    {
        $this->EntityID = $EntityID;
    }

    /**
     * Gets $ProxyURL.
     * @see Store::$ProxyURL
     */
    public function getProxyURL()
    {
        return $this->ProxyURL;
    }
    
    /**
     * Sets $ProxyURL.
     * @param object $ProxyURL
     * @see Store::$ProxyURL
     */
    public function setProxyURL($ProxyURL)
    {
        $this->ProxyURL = $ProxyURL;
    }
    
    /**
     * Gets $id.
     * @see Store::$id
     */
    public function getId()
    {
        return $this->id;
    }
    
    /**
     * Sets $id.
     * @param object $id
     * @see Store::$id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

}

?>